<?php
namespace Home\Model;
use Think\Model;
class UserModel extends Model {
    
    public function getUserListByPage($where,$page){
        $user = D('user');
       $userList=$user->where($where)->order('id desc')->page($page)->select();
        return $userList;
    }
    
 
    
	
	/**
     * 会员新增
     */
	public function addUser($data){
		$user = D('user');
		$data['createymd']= date("Ymd", time());
		$data['createtime']= time();
		$result = $user->add($data);
		return $result;
	}
		
    /**
     * 获取用户信息
     */
    public function getUserItem($where) {
		$user = D('user');
		$result = $user->where($where)->find();
		return $result;
    }

    /**
     * 会员更新
     */
    public function UpUser($where,$data){
        //会员更新
        $user = D('user');
        $result = $user->where($where)->save($data);
        return $result;
    }
    /**
     * 根据条件获取会员数量
     * @param unknown $where
     * @return unknown
     */
    public function getUserCount($where){
        $user = D('user');
        $count = $user->where($where)->count();
        return $count;
    }
    /**
     * 分页获取用户列表
     * @param   $where
     * @param   $page
     * @return  
     */
    public function getUserlist($where){
        $user = D('user');
        $result = $user->where($where)->select();
        return $result;
    }
    
    /**
     * 字段增加 数量
     * @param unknown_type $where  条件
     * @param unknown_type $column 字段
     * @param unknown_type $num  数量
     * @return unknown
     */
    public function setIncUser($where,$column,$num) {
    	$user = D('user');
        $result = $user->where($where)->setInc($column,$num); 
        return $result;
    }

    /**
     * 字段增加 数量
     * @param unknown_type $where  条件
     * @param unknown_type $column 字段
     * @param unknown_type $num  数量
     * @return unknown
     */
    public function setDecUser($where,$column,$num) {
    	$user = D('user');
        $result = $user->where($where)->setDec($column,$num); 
        return $result;
    }
    
} 